fix(view): sort and truncate dist-tags #7808
Merged
+105
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This sorts dist-tags by publish date so that newer tags show first,
giving top priority to the
latest
tag.It also truncates the list in a similar manner to how dependencies are
truncated.
Needs tests.
Before:
![dist-tags list in npm view showing every tag shorted by version](https://private-user-images.githubusercontent.com/36607/372959445-9a8b094f-f466-439c-927b-21dbeb896322.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMzE0ODcsIm5iZiI6MTczOTAzMTE4NywicGF0aCI6Ii8zNjYwNy8zNzI5NTk0NDUtOWE4YjA5NGYtZjQ2Ni00MzljLTkyN2ItMjFkYmViODk2MzIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDE2MTMwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRkZWU0ZjY0NTU0MDcwZTU1OTE1ZDY2Y2U5ZWYxZGJlOGY4ZjQyN2E3NTg2ZDU1MTZiNjY0YThmNzA2NmRhNmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.wqhPg-VHRs0b-1bDNs1p2pnxIeDScYW0Y1Rp8CIzAIE)
After:
![dist-tags list in npm view showing a truncated list sorted by publish date](https://private-user-images.githubusercontent.com/36607/372959612-8727c387-21ed-4fe3-8f09-dc8b93bfe75f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMzE0ODcsIm5iZiI6MTczOTAzMTE4NywicGF0aCI6Ii8zNjYwNy8zNzI5NTk2MTItODcyN2MzODctMjFlZC00ZmUzLThmMDktZGM4YjkzYmZlNzVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDE2MTMwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjNTY0NGU4MDEyN2RhYjAwODU1NjEyMjcxZTRlNTk1MDlhOGE5NjQwN2UwZGQ4ZmU5MzEyODViNDBhYTM2NzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WJILzaM7wbkuHUYiIkSH9jtx2kWn5zqvWC1t2vZKeOk)